package adv8;

import java.io.File;
import java.util.List;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

public class XMLRead2 {

	public static void main(String[] args) throws DocumentException {
		// 之查找姓名
		SAXReader reader = new SAXReader();
		Document doc = reader.read(new File("students2.xml"));
		Element root = doc.getRootElement();
		System.out.println(root.getName() + " 是根节点");
		// 利用xpath来查找节点
		// root.selectNodes("stduent");
		List<Element> list = doc.selectNodes("/stduents/student/name");
		for (Element e : list) {
			System.out.println(e.getText() + ">>>>");
		}
	}

}
